
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2
 * @Author : WangRuoyu 
 * @Date : 2023/5/11 10:22
 */

#include "iostream"
#include "cstring"
#include "algorithm"

using namespace std;

int main() {
    int n;
    cin >> n;
    int nums[n][n];

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> nums[i][j];
        }
    }

    for (int i = 0; i < 2 * n - 1; ++i) {
        if (i % 2) {
            if (i < n) {
                for (int j = 0, k = i; j <= i; ++j, --k) {
                    cout << nums[j][k] << " ";
                }
            } else {
                for (int j = i - n + 1, k = n - 1; j <= n - 1; ++j, --k) {
                    cout << nums[j][k] << " ";
                }
            }
        } else {
            if (i < n) {
                for (int j = i, k = 0; j >= 0; --j, ++k) {
                    cout << nums[j][k] << " ";
                }
            } else {
                for (int j = n - 1, k = i - n + 1; j >= i - n + 1; --j, ++k) {
                    cout << nums[j][k] << " ";
                }
            }
        }
    }

    return 0;
}